package BinaryTree;
/**
 * 左叶子之和
 */
import BinaryTree.init.TreeNode;

public class lc404 {

    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null) return 0;
        
        int sum = 0;
        if (root.left != null && root.left.left == null && root.left.right == null) {
            sum += root.left.val; // 直接加上左叶子节点的值
        }
        sum += sumOfLeftLeaves(root.left);  // 递归遍历左子树
        sum += sumOfLeftLeaves(root.right); // 递归遍历右子树
        return sum;
    }
    
}


